var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var path = require('path');
var module_dir = path.join(__dirname, 'node_modules');

config = {
    addVendor: function (name, path) {
        this.resolve.alias[name] = path;
        this.module.noParse.push(new RegExp(path));
    },
    resolve: { alias: {} },
    context: path.join(__dirname, "app"),
    entry: {
        // app: ['webpack/hot/dev-server', './main.jsx']
        app: './main.jsx'
        // app: './test/animation.jsx'
    },
    plugins: [
        //new webpack.optimize.CommonsChunkPlugin('common.js'), 
        new HtmlWebpackPlugin({
            template: 'app/base.html',
            inject: 'body',
            chunks: ['app', ]
        }),
    ],
    output: {
        path: path.join(__dirname, "dist"),
        filename: '[name].bundle.js',
        chunkFilename: "[id].chunk.js"
    },
    module: {
        noParse: [],
        loaders: [
            {test: /\.jsx?$/, exclude: /node_modules/, loaders: ["react-hot", "babel-loader"], },
            {test: /\.html$/, loader: "file?name=[name].[ext]", },

            {test: /\.css$/, loader: "style-loader!css-loader"},
            {test: /\.less/, loader: 'style-loader!css-loader!less-loader'}, 
            {test: /\.(png|jpg)$/, loader: 'url-loader?limit=8192'},

            {test: /\.(woff|woff2)$/,   loader: "url-loader?limit=10000&minetype=application/font-woff" },
            {test: /\.ttf$/,    loader: "file-loader" },
            {test: /\.eot$/,    loader: "file-loader" },
            {test: /\.svg$/,    loader: "file-loader" },

            // font-awesome, endswith ?xxx
            {test: /\.eot/,    loader: "file-loader" },
            {test: /\.(woff|woff2)/,   loader: "url-loader?limit=10000&minetype=application/font-woff" },
            {test: /\.svg/,    loader: "file-loader" },
            {test: /\.ttf/,    loader: "file-loader" },
        ],
    },
}

// config.addVendor('bootstrap', module_dir + '/bootstrap/dist/js/bootstrap.min.js');
// config.addVendor('bootstrap.css', module_dir + '/bootstrap/dist/css/bootstrap.min.css');

module.exports = config;
